package com.yun;

/**
 * Created by txl on 2018/3/13.
 */

/**
 * Created by txl on 2018/3/13.
 */
public class Sort{
    static int partition(int arr[],int low,int high){
        int pivot = arr[low];
        while (low < high) {
            while (low < high && arr[high] >= pivot) {
                --high;
                arr[low] = arr[high];
                while (low < high && arr[high] <= pivot)
                    ++low;
            }
        }
        arr[low] = pivot;
        return low;
    }
    static void Qsort(int arr[],int low,int high){
        if(low<high){
            int privot=partition(arr,low,high);
            Qsort(arr,low,privot-1);
            Qsort(arr,privot+1,high);

        }
    }
    static void QuickSort(int arr[],int n){
        Qsort(arr,0,n-1);
    }

    public static void main(String[] args) {
        int arr[]={3,45,12,44,88,90,61,7,5};
        QuickSort(arr, arr.length);
        for(int i=0;i<arr.length;i++){
            System.out.println(arr[i]);
        }
    }

}
